import request from '@/utils/request'
const ProductCategoryServices = {
  actions: {
    /**
     * 商品分类分页
     */
    productCategoryPage({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('productCategory/page', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 商品分类列表
     */
    productCategoryList({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('productCategory/list', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 商品分类新增
     */
    productCategorySave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('productCategory/save', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 商品分类修改
     */
    productCategoryUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('productCategory/update/' + params.id, {
          name: params.name,
          orders: params.orders
        }).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 商品分类删除
     */
    productCategoryRemove({ commit }, ids) {
      return new Promise((resolve, reject) => {
        request.post('productCategory/remove', ids).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    }
  }
}
export default ProductCategoryServices
